<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<include file='Common:head'/>

<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li>首页</li>
    <li>用户列表</li>
  </ul>
</div>
<div class="rightinfo">
  <div class="tools">
    <form action="{:U('Member/index')}" method="get">
      <ul class="toolbar">
        <a href="{:U('Member/add')}">
        <li><span><img src="__PUBLIC__/Admin/images/t01.png" /></span>添加</li>
        </a> <a id="del">
        <li><span><img src="__PUBLIC__/Admin/images/t03.png" /></span>删除</li>
        </a>
        <li><span>
          <input type="text" name="seach">
          </span>帐号</li>
        <li><span><img src="__PUBLIC__/Admin/images/t01.png" /></span><span style="margin-top:7px; font-size:16px;">
          <input type="submit" value="搜索">
          </span></li>
      </ul>
    </form>
  </div>
  <table class="tablelist">
    <thead>
      <tr>
        <th><input type="checkbox" id="selall"/></th>
        <th>ID</th>
        <th>帐号</th>
        <th>锁定</th>
        <th>登录IP</th>
        <th>登录时间</th>
        <th>最后登录时间</th>
        <th>登录次数</th>
        <th>操作</th>
      </tr>
    </thead>
    <tbody>
      <foreach name='member' item='v'>
      <if condition="$v['id'] neq 1">
        <tr>
          <td><input type="checkbox" class="selall" name="id[]" value="{$v['id']}"/></td>
          <td>{$v['id'] - 1}</td>
          <td>{$v['username']}</td>
          <td><?php
        	switch($v['lock']){
            	case 1:
                	echo "<a>正常</a>";
                    break;
                case 0:
                	echo "<a style='color:#F00;font-weight:bold;'>锁定</a>";
            }
        ?></td>
          <td>{$v['loginip']}</td>
          <td>{$v['logintime']|date='Y-m-d H:i',###}</td>
          <td>{$v['loginlast']|date='Y-m-d H:i',###}</td>
          <td>{$v['loginnum']}</td>
          <td>
              <a href="{:U('Member/edit',array('id'=>$v['id']))}" class="tablelink">编辑</a>&nbsp;&nbsp;
              <if condition=" $v['username'] neq 'admin' "> 
          	  |&nbsp;&nbsp;
              <a href="{:U('Member/del',array('id'=>$v['id']))}" class="tablelink" onclick="return confirm('确实要删除吗？')">删除</a>
              </if>
          </td>
        </tr>
      </if>  
      </foreach>
    </tbody>
  </table>
  <!--<div class="pagin">
   
	<div class="message">共<i class="blue">1256</i>条记录，当前显示第&nbsp;<i class="blue">2&nbsp;</i>页</div>
    <ul class="paginList">
          <li class="paginItem"><a href="javascript:;"><span class="pagepre"></span></a></li>
          <li class="paginItem"><a href="javascript:;">1</a></li>
          <li class="paginItem"><a href="javascript:;">3</a></li>
          <li class="paginItem"><a href="javascript:;">4</a></li>
          <li class="paginItem"><a href="javascript:;">5</a></li>
          <li class="paginItem"><a href="javascript:;">10</a></li>
          <li class="paginItem"><a href="javascript:;"><span class="pagenxt"></span></a></li>
    </ul>

  </div>-->
  <div class="meneame">
    <div class="current"></div>
    {$page} </div>
</div>
</div>
<script>
$('#selall').click(function(){
	var chk = $(this).attr('checked');//获取当前的属性
	if(chk){
		$(".selall").attr("checked","checked");//设置当前的属性
	}else{
		$(".selall").removeAttr("checked");//移除当前的属性
	}
});

$(function() {
    $("#selall").click(function() {
        $('input[name="id"]').attr("checked",this.checked); 
    });
    var $subBox = $("input[name='id']");
    $subBox.click(function(){
        $(".selall").attr("checked",$subBox.length == $("input[name='id']:checked").length ? true : false);
	
	});
	$("#del").click(function(){
		if(confirm("确定删除勾选内容吗？")){
            var v='';
            var m=$('input[name="id[]"]:checked').length;
            var i=1;
            $('input[name="id[]"]:checked').each(function(){
                if(i==m){
                    v+=$(this).val();
                }else{
                    v+=$(this).val()+",";
                }
                i=i+1;
            });
            if(!v){
                alert('请选择您要删除的内容！');
            }else{
				//alert(v);//获取到选中的值 1,2,3,4  
				$.ajax({ 
                    type     : "POST", 
                    url      : "{:U('Member/ajaxDel')}", 
					data     : {id:v},
					//async    :  false,//加同步才可以执行
					success  : function(data) {
						if(data == 1){
							alert('批量删除成功！');
							window.location.reload(); 
						}else{
							alert('批量删除失败！');
							return false;
						}
                    } 
                }); 
            }
        }else{
            return false;
        }
	});
});
</script>
</body>
</html>
